package ink.lovejinhu.leetcode;

/**
 * @Author: jin
 * @Date: 2021/9/10 20:51
 * @Version: V1.0
 * @Slogan: Great people are not born great, but show their greatness in the process of growing up
 **/
public class Solution_0896 {
    /**
     * 判断是否是一个单调队列
     *
     * @param nums
     * @return
     */
    public boolean isMonotonic(int[] nums) {
        if (nums.length <= 2) {
            return true;
        }
        if (nums[nums.length - 1] > nums[0]) {
            for (int i = 1; i < nums.length; i++) {
                if (nums[i] >= nums[i - 1]) {
                    continue;
                } else {
                    return false;
                }
            }
        } else if (nums[nums.length - 1] == nums[0]) {
            for (int i = 1; i < nums.length; i++) {
                if (nums[i] == nums[i - 1]) {
                    continue;
                } else {
                    return false;
                }

            }
        } else {
            for (int i = 1; i < nums.length; i++) {
                if (nums[i] <= nums[i - 1]) {
                    continue;
                } else {
                    return false;
                }
            }
        }
        return true;
    }
}
